package ipad.asia.controller;

import ipad.asia.dao.ProductCopyDao;
import ipad.asia.dao.ProductDao;
import ipad.asia.entity.Product;
import ipad.asia.entity.ProductCopy;
import ipad.asia.service.ProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ProductCopyController {

    @Autowired
    private ProductCopyDao productCopyDao;

    @PostMapping("/productCopy/saveObj")
    public void addObj(@RequestBody ProductCopy product){
        productCopyDao.save(product);
    }

    @RequestMapping("/productCopy/get/id")
    public ProductCopy getById(@RequestParam("id") int id)  {
        return productCopyDao.findById(id);
    }

    @RequestMapping("/productCopy/get/ShopId")
    public List<ProductCopy> getShopId(@RequestParam(value = "ShopId",required = false)int shopId) {
            return productCopyDao.findByShopId(shopId);
        }

    //删除
    @Transactional
    @RequestMapping("/productCopy/delete")
    public void DeleteById(@RequestParam(value = "id",required = false)int id){
         productCopyDao.deleteById(id);
    }


}
